<template>
    <base-breadcrumb :breadcrumb="!isAudit">
        <div class="page-detail">
            <title-name size="24" title="其他类合同"></title-name>
            <a-card>
                <title-name title="基本信息"></title-name>
                <a-descriptions>
                    <a-descriptions-item label="合同名称">{{ form1.contractName }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="所属分公司">{{ form1.branchCompany }}</a-descriptions-item>
                    <a-descriptions-item label="项目名称">{{ form1.project }}</a-descriptions-item>
                    <a-descriptions-item label="合同对方">{{ form1.otherParty }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="合同价（万元）">{{ form1.amount }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="合同简要内容">{{ form1.contractContent }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="主办人">{{ form1.creatorName }}</a-descriptions-item>
                    <a-descriptions-item label="主办人部门">{{ form1.sponsorName }}</a-descriptions-item>
                    <a-descriptions-item label="联系电话">{{ form1.creatorPhone }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="创建时间">{{ form1.createTime|dateFormat }}</a-descriptions-item>
                </a-descriptions>
            </a-card>
            <a-card>
                <title-name title="评审意见"></title-name>
                <table>
                    <thead>
                    <tr>
                        <th width="16.6%">评审部门</th>
                        <th width="16.6%">评审内容</th>
                        <th width="50%">评审意见</th>
                        <th width="16.6%">评审时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr v-for="item of form1.opinions">
                        <td>{{ item.department }}</td>
                        <td>
                            {{ item.agree === 'true' ? '同意' : '不同意' }}
                        </td>
                        <td>
                            {{ item.opinion }}
                        </td>
                        <td>
                            {{ item.createTime }}
                        </td>
                    </tr>
                    </tbody>
                </table>
            </a-card>
            <a-card v-if="$isEmpty(taskDefKey) || taskDefKey === 'legal_other_apply_bm_audit'">
                <title-name title="用印申请"></title-name>
                <a-descriptions>
                    <a-descriptions-item label="合同名称">{{ form2.contractName }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="合同对方">{{ form2.otherParty }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="申请单位">{{ form2.branchCompany }}</a-descriptions-item>
                    <a-descriptions-item label="合同价（万元）">{{ form2.amount }}</a-descriptions-item>
                    <a-descriptions-item label="合同类型">其他</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="合同份数">{{ form2.contractNum }}</a-descriptions-item>
                    <a-descriptions-item label="项目经理">{{ form2.realityPmName }}</a-descriptions-item>
                    <a-descriptions-item label="项目经理联系电话">{{ form2.realityPmPhone }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="经办人">{{ form2.creatorName }}</a-descriptions-item>
                    <a-descriptions-item label="职务">{{ form2.positionName }}</a-descriptions-item>
                    <a-descriptions-item label="经办人联系电话">{{ form2.creatorPhone }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="申请日期">{{ form2.createTime|dateFormat }}</a-descriptions-item>
                </a-descriptions>
                <a-descriptions>
                    <a-descriptions-item label="特别说明">{{ form2.specialNotes }}</a-descriptions-item>
                </a-descriptions>
            </a-card>
            <a-card v-if="form1.id">
                <title-name title="相关附件"></title-name>
                <u-table
                    :isShow="false"
                    businessCode="LCM08"
                    :listUrl="findFileList"
                    :uploadList="addFile"
                    :deleteUrl="deleteFile"
                    :businessId="form1.id">
                </u-table>
            </a-card>
            <div class="options">

            </div>
            <div class="tar page-btn-right-top">
                <a-button @click="$close"  v-checkVisibleInDetail >关闭</a-button>
            </div>
        </div>
    </base-breadcrumb>
</template>

<script>

import otherTypeApi from '@/api/legal/branchContract/otherType'

export default {
  name:'a'+Date.now(),
    props: {
        isAudit: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            addFile: otherTypeApi.addFile(),
            deleteFile: otherTypeApi.deleteFile(),
            findFileList: otherTypeApi.findFileList(),
            form1: {
                opinions: []
            },
            form2: {},
            loading: false,
            businessId: this.$route.query.businessId,
            taskDefKey: this.$route.query.taskDefKey,
        }
    },
    watch: {},
    mounted: async function() {
        if (this.businessId) {
            await this.getApplyData()
        } else {
            await this.getData()
        }
    },
    methods: {
        async getData() {
            this.loading = true
            let res = await otherTypeApi.findListByMainId({}, { id: this.$route.query.id })
            if (res.code === this.SUCCESS_CODE) {
                this.form1 = this.$assign(this.form1, res.data)
                let res2 = await otherTypeApi.findSealByBaseId({}, { id: this.form1.id })
                if (res2.code === this.SUCCESS_CODE) {
                    this.form2 = this.$assign(this.form2, res2.data)
                }
            }
            this.loading = false
        },
        async getApplyData() {
            this.loading = true
            let res = await otherTypeApi.findByBusinessId({}, { id: this.businessId })
            if (res.code === this.SUCCESS_CODE) {
                this.form1 = this.$assign(this.form1, res.data)
                let res2 = await otherTypeApi.findSealByBusinessId({}, { id: this.form1.sealBusinessId })
                if (res2.code === this.SUCCESS_CODE) {
                    this.form2 = this.$assign(this.form2, res2.data)
                }
            }
            this.loading = false
        }
    }
}
</script>
<style lang="less" scoped>
table {
    width: 100%;
    border: 1px solid gainsboro;

    thead {
        background: rgb(244, 244, 244);

        th {
            padding: 10px;
            border: 1px solid gainsboro;
        }
    }

    tbody {
        td {
            padding: 10px;
            border: 1px solid gainsboro;
        }
    }
}

</style>
